@extends('admin.common.base-master')

@section('html-head')
    {{--<link href="{{url('/vendor/tyupload/control/css/zyUpload.css')}}" type="text/css" rel="stylesheet" />--}}
    <link href="{{url('css/jquery.form.css')}}" type="text/css" rel="stylesheet" />
    {{--<script src="{{url('/vendor/My97DatePicker/WdatePicker.js')}}"></script>--}}
    <script src="{{url('/js/lib/jquery.form.js')}}"></script>

    <link rel="stylesheet" href="{{url('css/admin/jquery-ui.css')}}">
    <script type="text/javascript" src="{{url('css/admin/jquery-ui.min.js')}}"></script>
    <link href="{{url('js/lib/jquery-ui-timepicker-addon.css')}}" type="text/css" />
    <script src="{{url('js/lib/jquery-ui-timepicker-addon.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery.ui.datepicker-zh-CN.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery-ui-timepicker-zh-CN.js')}}" type="text/javascript"></script>

    <!-- 配置文件 -->
    <script type="text/javascript" src="{{url('/ueditor/ueditor.config.js')}}"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="{{url('/ueditor/ueditor.all.js')}}"></script>
    <style>
        .btn_add_classify{
            background: #31bcd3;margin-left:10px;height: 5px;width: 50px;color: white;text-align: center;padding:5px;border-radius:7px;box-shadow: 3px 2px 9px #888888;
        }
    </style>
@endsection

@section('html-body')
    <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">系统设置</a>
            <em>></em>
            <a href="{{route('Admin.Home.ordersList')}}">订单列表</a>
            <em>></em>
            <a href="#">发货信息设置设置</a>
        </div>

        <div class="gg-step">
            <form  id="advform">
                <input type="hidden" name="id" id="orderid" value="@if($thisOrder){{$thisOrder->id}}@endif"/>
                <div class="gg-list">
                    <label class="tit">收件人</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" readonly="readonly" value="@if($thisOrder){{$thisOrder->name}}@endif" /><cite id="title_re" class="required">*</cite>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">手机号</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" readonly="readonly" value="@if($thisOrder){{$thisOrder->phone}}@endif" /><cite id="title_re" class="required">*</cite>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">邮政编码</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" readonly="readonly" value="@if($thisOrder){{$thisOrder->postcode}}@endif" /><cite id="title_re" class="required">*</cite>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">发货地址</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" readonly="readonly" value="@if($thisOrder){{$thisOrder->Address}}@endif" /><cite id="title_re" class="required">*</cite>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">发货公司</label>
                    <div class="cont">
                        <select name="express_id" id="express_id">
                        @if(count($thisExpress) > 0)
                            @foreach($thisExpress as $thisExpr)
                                <option value="{{$thisExpr->id}}" @if($thisExpr && $thisExpr->is_default == 1)selected @endif>{{$thisExpr->name}}</option>
                            @endforeach
                        @endif
                        </select>
                    </div>
                </div>

                <div class="gg-list">
                    <label class="tit">配送单号</label>
                    <div class="cont">
                        <input class="gg-ipt" type="text" placeholder="请输入配送单号" name="express_num" id="express_num" value="@if($thisOrder){{$thisOrder->express_num}}@endif" /><cite id="title_re" class="required">*</cite>
                    </div>
                </div>

            </form>
            <div class="gg-list" >
                <label class="tit">&nbsp;</label>
                <div class="cont" >
                    <a href="javascript:;" class="next-step" id="btn-set">提交</a>
                </div>
            </div>
        </div>
    </div>

    <!-- content end -->
    <script>
        $(function() {
            jQuery('#express_time').datetimepicker({
                timeFormat: "HH:mm:ss",
                dateFormat: "yy-mm-dd",
                beforeShow: function () {
                    setTimeout(
                            function () {
                                $('#ui-datepicker-div').css("z-index", 1000);
                            }, 100
                    );
                }
            });

            $(document).on('click', '#btn-set', function () {
                var expressNum   = $('#express_num').val();
                var expressId    = $('#express_id option:selected').val();
                var id           = $('#orderid').val();

                $.ajax({
                    url: '{{route("Api.Admin.order.setShipInfo")}}',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        express_num: expressNum,
                        express_id:expressId,
                        id:id
                    },
                    success: function (obj) {
                        if (obj.level == "success") {
                            noty({
                                text: obj.message, type: obj.level, timeout: 600,
                                callback: {
                                    afterClose:function(){
                                        window.location.href = "{{route('Admin.Home.ordersList')}}?id="+id;
                                    }
                                }
                            });
                        } else if (obj.level == "error") {
                            noty({text: obj.message, type: onbj.level, timeout: 600});
                        }

                    },
                    error: function (obj) {
                        console.log(obj);
                    }
                });
            });
        });
    </script>
@endsection